{extend name="common:base-user" /}

{block name="title"}个人中心 - 天佑二手货{/block}
{block name="css"}
<link rel="stylesheet" href="__STATIC__/css/cropper.min.css" />
{/block}
{block name="page"}auth{/block}

{block name="main"}
<div class="">
    <div class="am-panel am-panel-default">
      <div class="am-panel-hd">
        <ul class="am-nav am-nav-pills nav-sort ">
            <li id="sort-deadline"><a href="{:url('goods/goodsList', ['status'=>$status])}/sort/deadline">剩余时间</a></li>
            <li id="sort-hits"><a  href="{:url('goods/goodsList', ['status'=>$status])}/sort/hits">点击量</a></li>
            <li id="sort-time"><a  href="{:url('goods/goodsList', ['status'=>$status])}/sort/time">创建时间</a></li>
            <script type="text/javascript">$('#sort-{$sort}').addClass('am-active');</script>
        </ul>
      </div>
      <table class="am-table">
                <thead>
                <tr>
                    <td class="table-id am-text-center">商品信息</td>
                    <td class="table-title">价格</td>
                    <td class="table-title am-text-center">状态</td>
                    <td class="table-type am-text-center">操作</td>
                </tr>
                </thead>
                <tbody>
                    {volist name="data" id="vo"}
                        <tr>
                            <td style="height: 80px;padding: 10px 0px 0px 0px;">
                                <div class="am-fl am-text-middle" style="width: 120px; height: 55px;padding: 0px 10px 0px 10px">
                                    <a href="{:url('goods/detail',['good_id' => $vo['good_id']])}" class="">
                                        <img src="__ROOT__{$vo.thumb?$vo.thumb:'/static/images/no-thumb.png'}" width="100" height="55" class=""/>
                                    </a>
                                </div>
                                <div class="am-fl am-text-middle " style="height: 55px;">
                                    <h6 class="am-margin-0"><a href="{:url('goods/detail',['good_id' => $vo['good_id']])}" class="am-text-truncate">{$vo.title}</a></h6>
                                    <div class="am-text-truncate">
                                        <small>剩余时间：{$vo.deadline|get_time_diff}</small>
                                    </div>
                                </div>
                            </td>
                            <td class="am-text-middle">￥{$vo.price}</td>
                            <td class="am-text-middle am-text-center">{$vo.status}</td>
                            <td class="am-text-middle am-text-center">
                                {if ($vo.status == "在售")}
                                    <button class="am-btn am-btn-default am-btn-xs am-text-secondary" onclick="ajax_notsell({$vo.good_id})" type="button">
                                            下架
                                            </button>
                                {/if}
                                {if ($vo.status == "审核未通过")}
                                    <button class="am-btn am-btn-default am-btn-xs am-text-secondary" onclick="ajax_through({$vo.good_id})" type="button"></span>
                                            再次申请审核
                                            </button>
                                {/if}
                                {if ($vo.status == "卖家下架" || $vo.status == "超时下架")}
                                    <button class="am-btn am-btn-primary am-btn-xs" onclick="ajax_sell({$vo.good_id})" type="button">
                                            上架
                                    </button>
                                    <button class="am-btn am-btn-warning am-btn-xs" onclick="ajax_recycle({$vo.good_id})" type="button">
                                            删除
                                    </button>
                                {/if}
                                {if ($vo.status == "已删除")}
                                    <button class="am-btn am-btn-primary am-btn-xs" onclick="ajax_outrecycle({$vo.good_id})" type="button">
                                    移出回收站
                                    </button>
                                {/if}
                            </td>
                        </tr>
                    {/volist}
                </tbody>
        </table>
      </table>
      {$data->render()}
    </div>

</div>
<div>
</div>
{/block}

{block name="js"}
<script type="text/javascript" src="__STATIC__/js/cropper.min.js"></script>
<script type="text/javascript">
function ajax_notsell(good_id) {
    $.post("{:url('goods/notSell')}",{'good_id':good_id}, function(data) {
        $alert = $('#am-alert');
        $alert.find('.content').text(data.msg);
        $alert.modal('open');
        if (data.code) {
            setTimeout(function() {
                location.reload();
            }, '800')
        }
    });
}
// 上架
function ajax_sell(good_id) {
    $.post("{:url('goods/sell')}",{'good_id':good_id}, function(data) {
        $alert = $('#am-alert');
        $alert.find('.content').text(data.msg);
        $alert.modal('open');
        if (data.code) {
            setTimeout(function() {
                location.reload();
            }, '800')
        }
    });
}
function ajax_recycle(good_id) {
    $.get("{:url('goods/recycle')}?good_id=" + good_id, function(data) {
        $alert = $('#am-alert');
        $alert.find('.content').text(data.msg);
        $alert.modal('open');
        if (data.code) {
            setTimeout(function() {
                location.reload();
            }, '800')
        }
    });
}
function ajax_outrecycle(good_id) {
    $.get("{:url('goods/outRecycle')}?good_id=" + good_id, function(data) {
        $alert = $('#am-alert');
        $alert.find('.content').text(data.msg);
        $alert.modal('open');
        if (data.code) {
            setTimeout(function() {
                location.reload();
            }, '800')
        }
    });
}
</script>
{/block}
